package com.itheima02;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2022-02-09
 * Time: 19:50
 */
/*需求：设计一个用于获取数组中元素最大值，调用方法并输出结果*/
public class MethodTest02 {
    public static void main(String[] args) {
        int[] arr = {6, 4, 2, 7, 9, 1, 0};
        System.out.println(getMax(arr));
    }

    public static int getMax(int[] arr) {
        int max = arr[0];
        for (int x = 0; x < arr.length; x++) {
            if (max < arr[x]) {
                max = arr[x];
            }
        }
        return max;
    }

}

